package main

import (
	"fmt"
	channel "golang-step/training/channel"
	"golang-step/training/function"
	"golang-step/training/goroutines"
	"golang-step/training/io"
	"golang-step/training/lock"
	"golang-step/training/loop"
	"golang-step/training/timeout"
	"golang-step/training/visibility"
	"golang-step/training/wait"
	_ "math"
	"time"
)

// the first init function in this go source file
func init() {
	fmt.Println("do in init1")
}

// the second init function in this go source file
func init() {
	fmt.Println("do in init2")
}

func main() {
	f := loop.Fib()
	// Function calls are evaluated left-to-right.
	fmt.Println(f(), f(), f(), f(), f())

	//file write and read
	io.WriteFile()
	io.ReadFile()

	//ioutil读取方式
	io.ReadByIo()

	//channel
	channel.RunChannel()
	channel.BufferedChannel()

	var i = 10
	var j float32
	j = float32(i)
	fmt.Println(j)

	//net.HttpGet()

	io.ExampleWriter()

	r := rune(0x41)
	fmt.Println(r)

	//日期操作
	t := time.Now()
	fmt.Println(t)
	fmt.Println(t.Date())
	fmt.Println(t)

	//结构体
	u := []struct {
		age  int
		name string
		tel  string
	}{{age: 20, tel: "18900000000", name: "mark"}, {20, "mark", "18900000000"}}

	fmt.Println(u[0])

	//可见性测试
	visibility.Public_fuction() //used in anywhere!
	//visibility.private_function() //不能访问私有函数，无法通过编译
	fmt.Println(visibility.P) //1
	//fmt.Println(visibility.p) //不能访问私有变量，无法通过编译
	fmt.Println(visibility.PI) //3.14
	//fmt.Println(visibility.pi) //不能访问私有常量，无法通过编译
	//fmt.Println(visibility._PI) //不能访问私有常量，无法通过编译

	//select示例
	timeout.ConnectionTimeOut()

	//类似countDownLaunch
	wait.Wait()

	//goroutine
	goroutines.GoRoutine()

	//lock
	lock.LockDemo()

	//函数作为参数
	function.Functional()

}
